﻿using IdentityService.Domain.Services;
using MediatR;

namespace IdentityService.Application.Commands
{
    public record UserModifyPasswordCommand(string OldPassword, string NewPassword) : IRequest<ModifyPasswordResult>;

    public class UserModifyPasswordCommandHandler : IRequestHandler<UserModifyPasswordCommand, ModifyPasswordResult>
    {
        private readonly IUserAccountService _service;
        public UserModifyPasswordCommandHandler(IUserAccountService service) => _service = service;

        public async Task<ModifyPasswordResult> Handle(UserModifyPasswordCommand request, CancellationToken cancellationToken)
        {
            return await _service.ModifyPasswordAsync(request.OldPassword, request.NewPassword);
        }
    }
}
